package Gui;

import javax.swing.JFrame;
import javax.swing.JPanel;

import client.ChatClient;
import client.SecretaryANDPrincipal;

public class Secretry extends JFrame 
{
	ChatClient client;
	JFrame MainFrame;
	SecretaryANDPrincipal secretary_Principal_obj;  //instance of secretary or principle we know if we look in the sign variable of the instance
	MainWindowSecretary1 MainWindowSecretary_panel;  //panel 1
	DefinisionOfCourse DefinisionOfCourse_panel;	//panel 2
	RemoveCourse RemoveCourse_panel; //panel 3
	UpdateCourse updateCourse_panel; //panel 4
	OpenNewCourse openNewCourse_panel;//panel 5
	DefinitionOfClass definitionOfClass_panel;//panel 6
	CreateClass createClass_panel; //panel 7
	UpdateClass updateClass_panel; //panel 8
	
	
	public Secretry(SecretaryANDPrincipal temp) //we get in the contractor the instance of SecretaryANDPrincipal
	{
		MainFrame = new JFrame();
		MainFrame.setSize(500, 500);
		
		secretary_Principal_obj=temp;
		
		DefinisionOfCourse_panel = new DefinisionOfCourse(this);		
		MainWindowSecretary_panel= new MainWindowSecretary1(this);
		RemoveCourse_panel=new RemoveCourse(this);
		updateCourse_panel=new UpdateCourse(this);
		openNewCourse_panel=new OpenNewCourse(this);
		definitionOfClass_panel= new DefinitionOfClass(this);
		createClass_panel=new CreateClass(this);
		updateClass_panel=new UpdateClass(this);
		
		
		MainFrame.add(MainWindowSecretary_panel);
		MainFrame.setVisible(true);
	}
	
	public void update_panel(int old_panel, int new_panel)
	{
		if(old_panel==1 && new_panel==2)
		{
			 MainFrame.remove(MainWindowSecretary_panel);
			 MainFrame.add(DefinisionOfCourse_panel);
			 setchanhe();
		}
		if(old_panel==2 && new_panel==1)
		{
			MainFrame.remove(DefinisionOfCourse_panel); 
			MainFrame.add(MainWindowSecretary_panel); 
			setchanhe();
		}
		if(old_panel==2 && new_panel==3)
		{
			MainFrame.remove(DefinisionOfCourse_panel); 
			MainFrame.add(RemoveCourse_panel); 
			setchanhe();
		}
		if(old_panel==3 && new_panel==2)
		{
			MainFrame.remove(RemoveCourse_panel); 
			MainFrame.add(DefinisionOfCourse_panel); 
			setchanhe();
		}
		if(old_panel==2 && new_panel==4)
		{
			MainFrame.remove(DefinisionOfCourse_panel); 
			MainFrame.add(updateCourse_panel); 
			setchanhe();
		}
		if(old_panel==4 && new_panel==2)
		{
			MainFrame.remove(updateCourse_panel); 
			MainFrame.add(DefinisionOfCourse_panel); 
			setchanhe();
		}
		if(old_panel==5 && new_panel==2)
		{
			MainFrame.remove(openNewCourse_panel); 
			MainFrame.add(DefinisionOfCourse_panel); 
			setchanhe();
		}
		if(old_panel==2 && new_panel==5)
		{
			MainFrame.remove(DefinisionOfCourse_panel); 
			MainFrame.add(openNewCourse_panel); 
			setchanhe();
		}
		
		if(old_panel==3 && new_panel==1)
		{
			MainFrame.remove(RemoveCourse_panel); 
			MainFrame.add(MainWindowSecretary_panel);
			setchanhe();
		}
		if(old_panel==1 && new_panel==6)
		{
			MainFrame.remove(MainWindowSecretary_panel); 
			MainFrame.add(definitionOfClass_panel);
			setchanhe();
		}
		if(old_panel==6 && new_panel==1)
		{
			MainFrame.remove(definitionOfClass_panel); 
			MainFrame.add(MainWindowSecretary_panel);
			setchanhe();
		}
		if(old_panel==6 && new_panel==7)
		{
			MainFrame.remove(definitionOfClass_panel); 
			MainFrame.add(createClass_panel);
			setchanhe();
		}
		if(old_panel==6 && new_panel==8)
		{
			MainFrame.remove(definitionOfClass_panel); 
			MainFrame.add(updateClass_panel);
			setchanhe();
		}
		if(old_panel==8 && new_panel==6)
		{
			MainFrame.remove(updateClass_panel); 
			MainFrame.add(definitionOfClass_panel);
			setchanhe();
		}
		if(old_panel==7 && new_panel==6)
		{
			MainFrame.remove(createClass_panel); 
			MainFrame.add(definitionOfClass_panel);
			setchanhe();
		}
		
	}
	
	public void setchanhe()
	{
		MainFrame.setVisible(false);
		MainFrame.setVisible(true);
	}


}
